package com.tyt.lelan.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.util.Log;

public class PubDateParser {
	
	//匹配样式
	private static final SimpleDateFormat PUBDATE_DATEFORMAT1 = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
	private static final SimpleDateFormat PUBDATE_DATEFORMAT2 = new SimpleDateFormat("EEE', 'd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);

	public static Date parse(String pubdate){
		
		
		Date date=null;
		if(pubdate==null) return null;
		if(date==null){
			
			try {
				date=PUBDATE_DATEFORMAT1.parse(pubdate);
				Log.v("=date=", date.toString());
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
						
		}
		
		if(date==null){
			try {
				date=PUBDATE_DATEFORMAT2.parse(pubdate);
				Log.v("=date=", date.toString());
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return date;
	}
	
}
